package com.myfum.mobile.tetris.utils
{
	import com.myfum.mobile.tetris.data.shapes.IShapeData;
	import com.myfum.mobile.tetris.data.shapes.LLeftShapeData;
	import com.myfum.mobile.tetris.data.shapes.LRightShapeData;
	import com.myfum.mobile.tetris.data.shapes.OShapeData;
	import com.myfum.mobile.tetris.data.shapes.SLeftShapeData;
	import com.myfum.mobile.tetris.data.shapes.SRightShapeData;
	import com.myfum.mobile.tetris.data.shapes.ShapeData;
	import com.myfum.mobile.tetris.data.shapes.TShapeData;
	
	import flare.materials.Material3D;
	import flare.materials.Shader3D;
	import flare.materials.filters.ColorFilter;

	public class MaterialFactory
	{
		public static function getMaterial(shapeData:ShapeData):Shader3D{
			var m:Shader3D = new Shader3D();
			var color:uint = getColor(shapeData);
			m.filters.push(new ColorFilter(getColor(shapeData)));
			m.build();
			return m;
		}
		
		public static function getColor(shapeData:ShapeData):uint{
			if(shapeData is LLeftShapeData || shapeData is LRightShapeData){
				return 0xff3300;
			}else if(shapeData is SLeftShapeData || shapeData is SRightShapeData){
				return 0x33ccff;
			}else if(shapeData is TShapeData){
				return 0x00ff33;
			}else if(shapeData is OShapeData){
				return 0x9933ff;
			}else if(shapeData is IShapeData){
				return 0xee0099;
			}else{
				return 0x33ff00;
			}
		}
	}
}